package com.job.project.event;

import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @Author 王博
 * @DateTime 2024-07-04 18:38
 */
@Component
public class MyEventListener {
    @Async
    @EventListener
    public void onApplicationEvent(MyEvent event) throws Exception{
        System.out.println(LocalDateTime.now()+":监听到事件：" + event.getMsg());
        System.out.println(LocalDateTime.now()+":onApplicationEvent:"+Thread.currentThread().getName());
        System.out.println(LocalDateTime.now()+":onApplicationEvent:"+Thread.currentThread().getThreadGroup().getName());
    }
}
